<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="train-item">
    <view class="train-item-cover">
      <image class="train-item-img" :src="info.cover_img" mode="aspectFill" />
      <view class="train-item-position">
        <image
          class="train-item-position2"
          src="@/package/novice/static/index-train.png"
        />
        {{ info.city_name }}
      </view>
    </view>
    <view class="train-item-content">
      <view class="train-item-name">{{ info.title }}</view>
      <view class="train-item-desc">{{ info.sub_title }}</view>
      <view style="display: flex; align-items: center">
        <view class="train-item-tag" v-for="i of info.tag_arr" :key="i">
          {{ i }}
        </view>
      </view>
      <view class="train-item-price">
        <view class="train-item-price2">首期款</view>
        <view class="train-item-price3">
          <text class="train-item-price4">¥</text>{{ info.price }}
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.train-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 20rpx;
  border-radius: 20rpx;
  background-color: #ffffff;

  .train-item-cover {
    position: relative;
    flex-shrink: 0;
  }

  .train-item-img {
    display: block;
    width: 148rpx;
    height: 192rpx;
    border-radius: 20rpx;
  }

  .train-item-position {
    position: absolute;
    left: 10rpx;
    bottom: 10rpx;
    display: flex;
    align-items: center;
    height: 32rpx;
    padding: 0 10rpx;
    font-size: 20rpx;
    color: #ffffff;
    white-space: nowrap;
    border-radius: 8rpx;
    background-color: rgba(0, 0, 0, 1);
  }

  .train-item-position2 {
    width: 20rpx;
    height: 20rpx;
    margin-right: 6rpx;
  }

  .train-item-content {
    flex-grow: 1;
    min-width: 0;
    margin-left: 20rpx;
  }

  .train-item-name {
    max-height: 80rpx;
    margin-bottom: 16rpx;
    font-size: 28rpx;
    color: #2d2d2d;
    line-height: 40rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .train-item-desc {
    margin-bottom: 10rpx;
    font-size: 24rpx;
    color: #999999;
    line-height: 34rpx;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .train-item-tag {
    padding: 0 10rpx;
    margin-right: 10rpx;
    font-size: 20rpx;
    color: #ff5d1f;
    line-height: 32rpx;
    border-radius: 8rpx;
    background-color: #fff7f3;
  }

  .train-item-price {
    position: absolute;
    right: 20rpx;
    bottom: 20rpx;
    display: flex;
    align-items: center;
  }

  .train-item-price2 {
    font-size: 26rpx;
    color: #666666;
    line-height: 36rpx;
  }

  .train-item-price3 {
    margin-left: 10rpx;
    font-size: 36rpx;
    color: #ff292c;
    line-height: 50rpx;
    font-weight: bold;
  }

  .train-item-price4 {
    margin-right: 4rpx;
    font-size: 24rpx;
    line-height: 34rpx;
  }
}
</style>